<template>
  <div>
    <button @click="click">post方法增加headers</button>
    <button @click="proxy">代理</button>
    <button @click="json">jsonserver</button>
  </div>
</template>

<script>
import apis from '@/api/api'
import axios from 'axios'
export default {
  bootstrap() {
    console.log('bootstrap')
  },
  data() {
    return {
      message: 'message'
    }
  },
  methods: {
    click() {
      apis.login(
        { username: 'admin', password: '123456' },
        {
          headers: {
            'myHeaders': 'custom',
            'Content-Type': 'application/json;'
          }
        }
      ).then(data => {
        console.log(data)
      }).catch((err) => {
        console.log(err)
      })
    },
    proxy() {
      apis.getlunbo({}).then((res) => {
        console.log(res)
      }).catch((err) => {
        console.log(err)
      })
    },
    json() {
      let axi = axios.create()
      axi.get('http://localhost:3000/posts/1').then((res) => {
        console.log(res)
      }).catch((err) => {
        console.log(err)
      })
    }
  }
}
</script>
